package com.hzjy.api.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.hzjy.api.beans.HzjyHotOriginators;
import com.hzjy.api.beans.HzjyHotOriginatorsDTO;
import com.hzjy.api.service.impl.HzjyHotOriginatorsServiceImpl;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hzjy.common.annotation.Log;
import com.hzjy.common.core.controller.BaseController;
import com.hzjy.common.core.domain.AjaxResult;
import com.hzjy.common.enums.BusinessType;
import com.hzjy.common.utils.poi.ExcelUtil;
import com.hzjy.common.core.page.TableDataInfo;

/**
 * 热门权益人榜单(每天0点更新榜单)Controller
 *
 * @author hzjy
 * @date 2020-08-29
 */
@RestController
@RequestMapping("/api/originators")
public class HzjyHotOriginatorsController extends BaseController {
    @Autowired
    private HzjyHotOriginatorsServiceImpl hzjyHotOriginatorsService;

    /**
     * 查询热门权益人榜单(每天0点更新榜单)列表
     */
    @GetMapping("/list")
    public AjaxResult list(HzjyHotOriginators hzjyHotOriginators) {
        Integer currentPage = hzjyHotOriginators.getCurrentPage();
        Integer size = hzjyHotOriginators.getSize();
        if (currentPage != null && size != null){
            hzjyHotOriginators.setCurrentPage((currentPage - 1)* size);
        }else {
            hzjyHotOriginators.setCurrentPage(0);
            hzjyHotOriginators.setSize(10);
        }
        Integer num = hzjyHotOriginatorsService.selectHzjyHotOriginatorsNum(hzjyHotOriginators);
        List<HzjyHotOriginatorsDTO> list = hzjyHotOriginatorsService.selectHzjyHotOriginatorsList(hzjyHotOriginators);
        Map map = new HashMap();
        map.put("hotOriginatorList", list);
        map.put("total", num);
        return AjaxResult.success(200,"查询成功",map);
    }
}
